<template>
	<view class="container">
		<star-nav title="会员中心" :type="3" icon="/static/myimages/m10.png">

		</star-nav>
		<view class="contenr">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y">
				<view v-for="(item,index) in list" :key="index" class="numberVip" :style="item.back">
					<view class="vipHeader">
						<view>{{item.vipName}}</view>
						<view class="activationEnergy">
							<image src="/static/hb.png" mode="widthFix" style="width: 50rpx;margin-right: 10rpx;margin-bottom: 10rpx;"></image>
							<view style="font-size: 50rpx;line-height: 1;">{{item.activationEnergy}}</view>
							<!-- <view style="font-size: 48rpx;">{{item.type==1?'/'+item.day+'天':''}}</view> -->
						</view>
					</view>
					<view class="vipPoints"></view>
					<view v-for="(t,i) in item.details" :key="i" class="vipDetail">
						<view class="ok" :style="item.color">✔</view>
						<view>{{t}}</view>
					</view>
					<view style="width: 100%;height: 40rpx;"></view>
					<u-button v-if="item.type!=2" :style="item.color" :custom-style="customStyleBtn1" :loading="loading"
						@click="handleVip(item)">
						立即兑换
					</u-button>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		vipCardList,
		redemption
	} from '@/api/my.js'
	export default {
		data() {
			return {
				loading: false,
				customStyleBtn1: {
					width: '650rpx',
					height: '80rpx',
					borderRadius: '20rpx',
					background: "#FFFFFF",
					fontSize: '33rpx',
					fontWeight: 800,
					color: '#F87E14',
					border: 'none',
					lineHight: '50rpx !important',
					letterSpacing: '1px',
					isEye: false
				},
				scrollTop: 0,
				list: []
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			async getList() {
				let res = await vipCardList()
				this.list = res.data.vipCardList.map((item, index) => {
					return {
						...item,
						back: index % 2 ? 'background: linear-gradient(to bottom, #F6960D, #F77F14)' :
							'background: linear-gradient(to bottom, #6995F9, #806CF5)',
						color: index % 2 ? 'color:#F68212' : 'color:#326CEC'
					}
				})
			},
			async handleVip(item) {
				try {
					this.loading = true
					let res = await redemption({vipCardId:item.id})
					this.loading = false
					uni.showToast({
						title:'兑换成功',
						icon:'none'
					})
				} catch (error) {
					this.loading = false
				}
			}
		}
	}
</script>

<style scoped>
	.activationEnergy {
		height: 50rpx;
		display: flex;
		align-items: flex-end;
		/* border-bottom: 1rpx solid #000000; */
	}

	.ok {
		width: 30rpx;
		height: 30rpx;
		border-radius: 30rpx;
		background-color: #FFFFFF;
		color: #F68212;
		font-size: 18rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 25rpx;
		margin-top: 7rpx;
	}

	.vipDetail {
		width: 100%;
		display: flex;
		/* align-items: center; */
		/* flex-direction: column; */
		margin-bottom: 10rpx;
		color: #FFFFFF;
		font-size: 28rpx;
		opacity: 1;
	}

	.vipPoints {
		font-size: 29rpx;
		margin-top: 30rpx;
		color: #FFFFFF;
		opacity: 0.8;
	}

	.vipHeader {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-weight: bold;
		font-size: 40rpx;
		color: #FFFFFF;
	}

	.numberVip {
		width: 710rpx;
		min-height: 200rpx;
		border-radius: 30rpx;
		display: flex;
		flex-direction: column;
		padding: 40rpx;
		box-sizing: border-box;
		margin-bottom: 40rpx;
		background-color: antiquewhite;
	}

	.scroll-Y {
		width: 100%;
		height: calc(100vh - 316rpx);
		display: flex;
		flex-direction: column;
	}

	.contenr {
		width: 100%;
		height: calc(100vh - 316rpx);
		display: flex;
		flex-direction: column;
		padding: 50rpx 20rpx 10rpx 20rpx;
		box-sizing: border-box;

	}

	.container {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
	}

	page {
		width: 100%;
		height: 100vh;
		background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
	}
</style>